﻿using AtentoFramework2008.TestTools.DomainModel;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NStore.Domain;
using NHibernate.Type;

namespace NStore.Infrastructure.Tests.MappingFile
{
    [TestClass]
    public class ProductTest : BaseTest
    {
        [TestMethod]
        public void ShouldBePersistent()
        {
            SpecifyOn.Entity<Product>().ShouldBePersistent().MappedToTable("Products");
        }

        [TestMethod]
        public void Id_IsIdentifierProperty()
        {
            SpecifyOn.Entity<Product>().ShouldHaveProperty("Id").ShouldBePersistent()
                .MappedToColumn("Id")
                .MappedWithIdentifierProperty();
        }

        [TestMethod]
        public void Name_ShouldBePersistent()
        {
            SpecifyOn.Entity<Product>().ShouldHaveProperty("Name").ShouldBePersistent()
                .MappedToColumn("Name")
                .MappedWithLength(100)
                .MappedWithUnique()
                .MappedWithType<StringType>();
        }

        [TestMethod]
        public void Description_ShouldBePersistent()
        {
            SpecifyOn.Entity<Product>().ShouldHaveProperty("Description").ShouldBePersistent()
                .MappedToColumn("Description")
                .MappedWithLength(500)
                .MappedWithType<StringType>();
        }

        [TestMethod]
        public void Quantity_ShouldBePersistent()
        {
            SpecifyOn.Entity<Product>().ShouldHaveProperty("Quantity").ShouldBePersistent()
                .MappedToColumn("Quantity")
                .MappedWithType<Int32Type>();
        }

        [TestMethod]
        public void Category_ShouldBePersistent()
        {
            SpecifyOn.Entity<Product>().ShouldHaveProperty("Category").ShouldBePersistent()
                .MappedToColumn("Category")
                .MappedWithType<PersistentEnumType>();
        }

        [TestMethod]
        public void Prices_ShouldBePersistent()
        {
            SpecifyOn.Entity<Product>().ShouldHaveProperty("Price").ShouldBePersistent()
                .MappedToColumn("Price")
                .MappedWithType<SingleType>();
        }
    }
}
